package com.larry.rabbitmq.seventh;

import com.larry.rabbitmq.util.RabbitMQUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;

/**
 * @author larry
 * @Title: larry-rabbitmq
 * @Package com.larry.rabbitmq.seventh
 * @Description: 主题模式
 * @date 7/1/2110:15 PM
 */
public class ReceiveLogsTopic01 {

    public static final String EXCHANGE_NAME = "topic_logs";

    public static void main(String args[]) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();

        //声明交换机
        channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);

        //声明队列
        String queueName = "Q1";
        channel.queueDeclare(queueName,false,false,false,null);

        //绑定
        channel.queueBind(queueName,EXCHANGE_NAME,"*.orange.*");

        //接收消息
        channel.basicConsume("Q1",true,(consumerTag, message) -> {
            System.out.println("01收到的消息.....: " + new String(message.getBody()));
        },consumerTag -> {});
    }
}
